<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			/**
			 * @param {number} x
			 * @return {number}
			 */
			var reverse = function(x) {
				let f = true;
				if (x < 0) {
					x = Math.abs(x);
					f = false
				}
				let s = x + "";
				let result = "";
				for (let i = s.length - 1; i >= 0; i--) {
					result += s[i];
				}
				//leetcode题目要求，但是js不用考虑这些问题，下面这行可以不要。
				if(result < (-2)**31 || result > (2**31-1)) return 0;
				if (f) {
					return +result;
				} else {
					return -(+result);
				}
			};
			console.log(reverse(-123));
		</script>
	</body>
</html>
